import { UIController } from "../../../Script/UIController";
import { UILayer } from "../../../Script/UIMgr";
import { MyInfoMgr, MyInfoEvent } from "./MyInfoMgr";

export class UI_MyInfo extends UIController {
    constructor() {
        super('ui/prefab/UI_MyInfo', UILayer.HUD);
    }

    onCreated() {
        this.onButtonEvent('btn_close', ()=>{
            this.hide();
        });

        // 改变数据
        this.onButtonEvent('introduce/btn_refresh', ()=>{
            MyInfoMgr.inst.changeIntroduce();
        });

        // 响应改变数据
        this.on(MyInfoEvent.INTRODUCE_CHANGED, ()=>{
            this.refreshIntroduce();
        });
    }

    refreshIntroduce() {
        this.node.getChildByName('introduce').getComponent(cc.Label).string = MyInfoMgr.inst.introduce;
    }
}